﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SqlMiM.Common.ViewModel;
using System.Collections.ObjectModel;
using SqlMiM.Common.Model;

namespace SqlMiM.SqlIndexes.Model
{
    public class FragmentedIndex : Index 
    {
        private byte fragmentation_level;
        private double avg_fragmentation_in_percent;
        private Double size;
        private Int32 rows;
        private Int64 page_count;
        private Int64 user_seeks;
        private Int64 user_scans;
        private DateTime? last_user_seek;
        private DateTime? last_user_scan;
        private DateTime? last_user_update;

        public FragmentedIndex()
        {
        }


        public Double Avg_fragmentation_in_percent
        {
            get
            {
                return avg_fragmentation_in_percent;
            }
            set
            {
                avg_fragmentation_in_percent = value;
            }
        }

        public byte Fragmentation_level
        {
            get 
            {
                if (this.avg_fragmentation_in_percent <= 30d)
                    fragmentation_level = 1;
                else if (this.avg_fragmentation_in_percent > 30d && this.avg_fragmentation_in_percent <= 60d)
                    fragmentation_level = 2;
                else
                    fragmentation_level = 3;

                return fragmentation_level; 
            }
            
        }

        public Double Size
        {
            get
            {
                return size;
            }
            set
            {
                size = value;
            }
        }

        public Int32 Rows
        {
            get
            {
                return rows;
            }
            set
            {
                rows = value;
            }
        }

        public Int64 Page_count
        {
            get
            {
                return page_count;
            }
            set
            {
                page_count = value;
            }
        }

        public Int64 User_seeks
        {
            get
            {
                return user_seeks;
            }
            set
            {
                user_seeks = value;
            }
        }

        public Int64 User_scans
        {
            get
            {
                return user_scans;
            }
            set
            {
                user_scans = value;
            }
        }

        public DateTime? Last_user_seek
        {
            get
            {
                return last_user_seek;
            }
            set
            {
                last_user_seek = value;
            }
        }

        public DateTime? Last_user_scan
        {
            get
            {
                return last_user_scan;
            }
            set
            {
                last_user_scan = value;
            }
        }

        public DateTime? Last_user_update
        {
            get
            {
                return last_user_update;
            }
            set
            {
                last_user_update = value;
            }
        }

    }

}
